import { Tag } from "antd"
import { ColumnGroupType, ColumnType } from "antd/es/table"

import { IResponseItem } from "@/api/funds/agentWithdrawalReviewRecord/types"
import { timeTurner } from "@/utils"
import { handleNumber } from "@/utils/util"

const AgentWithdrawalReviewRecordColumns = (
	newFormat: (arg: string) => string,
	getLabel: (value: string | number, modal: string, strictlyLabel?: boolean, customDictArr?: any[]) => any
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	agent_merchantName: {
		title: newFormat("common.belong_merchant"),
		dataIndex: "merchantName",
		key: "merchantName",
		render: (text: string) => (text ? text : "-"),
		align: "center",
		width: 150
	},
	agent_orderAmount: {
		title: newFormat("funds.fund_audit.order_withdraw_amount"),
		dataIndex: "orderAmount",
		key: "orderAmount",
		align: "center",
		render: (text: string, record: any) => (
			<span>
				{handleNumber(record.symbolUsdt, record.orderAmountUsdt)}
				{record.withdrawType === 1 && <br />}
				{record.withdrawType === 1 && `(${handleNumber(record.symbolCny, record.orderAmountCny)})`}
			</span>
		),
		width: 150
	},
	agent_isBig: {
		title: newFormat("funds.fund_audit.big_withdraw"),
		dataIndex: "isBig",
		key: "isBig",
		align: "center",
		render: (text: string, record: any) => (
			<span style={{ color: Number(record.bigWithdraw) === 1 ? "red" : "" }}>
				{Number(record.bigWithdraw) === 1 ? newFormat("common.yes") : newFormat("common.no")}
			</span>
		),
		width: 150
	},
	agent_payType: {
		title: newFormat("funds.pay_type"),
		dataIndex: "payType",
		key: "payType",
		align: "center",
		render: (text: string, record: any) => (
			<>
				{(Number(record.withdrawType) === 1
					? newFormat("funds.proxy_member_funds_record.brank_card")
					: newFormat("funds.proxy_member_funds_record.virtual_currency")) || "-"}
			</>
		),
		width: 150
	},
	agent_orderStatus: {
		title: newFormat("funds.fund_audit.order_status"),
		dataIndex: "orderStatus",
		key: "orderStatus",
		align: "center",
		render: (text: number, record: any) => {
			const getStatusColor = (status: number) => {
				switch (status) {
					case 11:
						return "success"
					default:
						return "error"
				}
			}

			return !!text || text == 0 ? (
				<Tag color={getStatusColor(record.orderStatus)}>{getLabel(text, "withdrawOrderStatus", false)}</Tag>
			) : (
				"-"
			)
		},
		width: 130 * 1.5
	},
	agent_details: {
		title: newFormat("funds.fund_audit.audit_time"),
		dataIndex: "audit1Time",
		key: "audit1Time",
		align: "center",
		render: (text: string, record: IResponseItem) => {
			return (
				<>
					{text ? (
						<div>
							<p>
								{newFormat("funds.fund_audit.audit_text_1")}：{record.audit1Time || "-"}
							</p>
							{record.audit2Time && (
								<p>
									{newFormat("funds.fund_audit.audit_text_2")}：{record.audit2Time || "-"}
								</p>
							)}
							{record.audit3Time && (
								<p>
									{newFormat("funds.fund_audit.audit_text_3")}：{record.audit3Time || "-"}
								</p>
							)}
							{record.confirmTime && (
								<p>
									{record.orderStatus === 12
										? newFormat("funds.fund_audit.cancel_pay")
										: newFormat("funds.fund_audit.confirm_pay")}
									：{record.confirmTime || "-"}
								</p>
							)}
						</div>
					) : (
						<span>-</span>
					)}
				</>
			)
		},
		width: 220
	},
	agent_audit1Cost: {
		title: newFormat("funds.fund_audit.audit_cost"),
		dataIndex: "audit1Cost",
		key: "audit1Cost",
		align: "center",
		render: (text: number, record: IResponseItem) => {
			return (
				<>
					{text || text === 0 ? (
						<div>
							<p>
								{newFormat("funds.fund_audit.audit_text_1")}：{timeTurner(record.audit1Cost) || "-"}
							</p>
							{(record.audit2Cost || record.audit2Cost === 0) && (
								<p>
									{newFormat("funds.fund_audit.audit_text_2")}：{timeTurner(record.audit2Cost) || "-"}
								</p>
							)}
							{(record.audit3Cost || record.audit3Cost === 0) && (
								<p>
									{newFormat("funds.fund_audit.audit_text_3")}：{timeTurner(record.audit3Cost) || "-"}
								</p>
							)}
							{(record.confirmCost || record.confirmCost === 0) && (
								<>
									{record.orderStatus === 12
										? newFormat("funds.fund_audit.cancel_pay")
										: newFormat("funds.fund_audit.confirm_pay")}
									:{timeTurner(record.confirmCost) || "-"}
								</>
							)}
						</div>
					) : (
						<span>-</span>
					)}
				</>
			)
		},
		width: 150
	},
	agent_audit1Operator: {
		title: newFormat("funds.fund_audit.lock_account"),
		dataIndex: "audit1Operator",
		key: "audit1Operator",
		align: "center",
		render: (text: number, record: IResponseItem) => {
			return (
				<>
					{text ? (
						<div>
							<p>
								{newFormat("funds.fund_audit.audit_text_1")}：{record.audit1Operator || "-"}
							</p>
							{record.audit2Operator && (
								<p>
									{newFormat("funds.fund_audit.audit_text_2")}：{record.audit2Operator || "-"}
								</p>
							)}
							{record.audit3Operator && (
								<p>
									{newFormat("funds.fund_audit.audit_text_3")}：{record.audit3Operator || "-"}
								</p>
							)}
							{record.confirmOperator && (
								<>
									{record.orderStatus === 12
										? newFormat("funds.fund_audit.cancel_pay")
										: newFormat("funds.fund_audit.confirm_pay")}
									:{record.confirmOperator || "-"}
								</>
							)}
						</div>
					) : (
						<span>-</span>
					)}
				</>
			)
		},
		width: 180
	}
})

export default AgentWithdrawalReviewRecordColumns
